decorative banner

Turning a dial and illuminating a lamp (linking opacity and rotation values)


    The following example shows how to use the pick whip to simulate dimming a light bulb while rotating a dial. This expression links the opacity values to the rotation values so that as the rotation changes, the opacity changes too.

    Note: To learn what the text in an expression means, see Understanding the expression language.

To link opacity values to rotation values:

  1. Start with a composition containing two layers: one to be used as the switch that you'll rotate, and one to be used as the object that changes in opacity as you rotate the switch. (We used two Adobe Illustrator files and named one "robot" and the other "switch.")
  2. Create keyframes to animate the rotation of the switch layer.
  3. Select the Opacity property for the robot layer and choose Animation > Add Expression. A default expression appears under the property.
  4. Click the pick whip next to the Opacity expression and drag it to the Rotation property for the switch layer. After Effects automatically fills in the following expression:
  5. thisComp.layer("switch.ai").rotation
  6. Preview the animation. Notice that the Opacity property of the robot layer is animated, yet there are no opacity keyframes.
  7. Note: Make sure to use rotation values that are compatible with the Opacity property. For example, opacity values range from 0 to 100, so rotating the switch layer backward using a negative value results in an opacity value of 0.

    Illustration of an expression linking opacity and rotation. The /5 modifier makes the change more gradual.
    Expression linking opacity and rotation. The "/5" modifier makes the change more gradual.